Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: add gatekeeper-auth example. #1963

Merged
merged 40 commits into from
Nov 18, 2024
Merged

Conversation

thruflo
Copy link
Contributor

@thruflo thruflo commented Nov 11, 2024

See https://github.com/electric-sql/electric/tree/thruflo/gatekeeper-auth-example/examples/gatekeeper-auth -- the example folder and subfolders all have READMEs.

I haven't yet updated the auth guide. I suspect it's best to merge this and update the guide in a separate PR.

@thruflo thruflo changed the title examples: Elixir/Phoenix-based gatekeeper and proxy auth example. examples: Elixir/Phoenix-based gatekeeper and proxy auth. Nov 11, 2024
scope "/gatekeeper" do
pipe_through :gatekeeper

post "/:table", Electric.Phoenix.Gateway.Plug, client: &Authenticator.client/0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@magnetised the client syntax / concept isn't the most obvious here. It's great that we can technically pass in an Authenticator via the client option. However the reason to be using a "client" in this context isn't super obvious. I'd much rather write e.g.:

post "/:table", Electric.Phoenix.Gateway.Plug, authenticator: {MyAuthenticator, []}

Or even just the function that generates the auth headers:

post "/:table", Electric.Phoenix.Gateway.Plug, auth_headers: &MyAuthenticator.authenticate_shape/2

Following the thought, that Authenticator.authenticate_shape/2 function gets the shape and a config options keyword list. It doesn't get the conn. Which, when generating an auth token, might be useful context, for example to put a user_id in the token, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good points.

Copy link

netlify bot commented Nov 13, 2024

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 8c20344
🔍 Latest deploy log https://app.netlify.com/sites/electric-next/deploys/6737130b9ba6c80008e84286
😎 Deploy Preview https://deploy-preview-1963--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@thruflo thruflo changed the title examples: Elixir/Phoenix-based gatekeeper and proxy auth. examples: gatekeeper-auth example. Nov 13, 2024
@thruflo thruflo changed the title examples: gatekeeper-auth example. examples: add gatekeeper-auth example. Nov 13, 2024
@thruflo thruflo marked this pull request as ready for review November 13, 2024 23:06
@thruflo thruflo added documentation Improvements or additions to documentation example labels Nov 13, 2024
Copy link
Contributor

@kevin-dp kevin-dp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have to go through the actual code but the readme is 🔥
Concise, clear, and to the point. Great job! 🥇

examples/gatekeeper-auth/README.md Outdated Show resolved Hide resolved
examples/gatekeeper-auth/README.md Show resolved Hide resolved
examples/gatekeeper-auth/README.md Show resolved Hide resolved
examples/gatekeeper-auth/README.md Outdated Show resolved Hide resolved
examples/gatekeeper-auth/README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@magnetised magnetised left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent

examples/gatekeeper-auth/README.md Outdated Show resolved Hide resolved
examples/gatekeeper-auth/README.md Outdated Show resolved Hide resolved
examples/gatekeeper-auth/README.md Show resolved Hide resolved
@thruflo thruflo merged commit 640fc04 into main Nov 18, 2024
26 of 27 checks passed
@thruflo thruflo deleted the thruflo/gatekeeper-auth-example branch November 18, 2024 16:25
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation example
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants